package com.jps;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.binder.BinderHeaders;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * create by lenovo 2020/10/2
 */

@RestController
public class OrderlyController {
    @Autowired
    private Source source;

    @GetMapping("/orderly")
    public String orderly(){
        List<String> list = Arrays.asList("创建","支付","退款");
        for (String s:list
             ) {
            MessageBuilder<String> builder = MessageBuilder.withPayload(s).setHeader(BinderHeaders.PARTITION_HEADER,0);
            Message<String> message = builder.build();
            source.output().send(message);
        }



        return "success.";
    }
}
